<?php defined('SYS_PATH') or die('No direct script access.');
/**
 * Application bootstrap
 * 
 * @author zendzhang<zendzhang@hotmail.com>
 * @version $Id: Bootstrap.php 8 2013-01-11 09:04:00Z zendzhang@hotmail.com $
 */
// Load the core TrueBlood class
require SYS_PATH . '/TrueBlood.php';
require SYS_PATH . '/Loader.php';
require APP_PATH . '/configs/define.inc.php';

//error display
if (DEBUG)
{
    //displays error messages and debug
    error_reporting(E_ALL ^ E_NOTICE);
    ini_set('display_errors', 'On');
}
else
{
    //do not display any error message
    error_reporting(0);
    ini_set('display_errors', 'Off');
}

// Set the default time zone.
date_default_timezone_set(TIMEZONE);

// Instantiate loader
$load = TrueBlood_Loader();
TrueBlood::loader($load);

// Enable custom autoload
spl_autoload_register(array($load, 'loadClass'));

// Removes slashes if magic quotes is on to keep things consistent
if (get_magic_quotes_gpc())
{
    $_GET = array_map(array($load->request, 'stripslashes'), $_GET);
    $_POST = array_map(array($load->request, 'stripslashes'), $_POST);
    $_COOKIE = array_map(array($load->request, 'stripslashes'), $_COOKIE);
}

// Dispatching the matched route
try {
    $load->router->dispatch();
} catch (Exception $e) {
	echo $e->getMessage(); exit;
}

// Get loader
function &TrueBlood_Loader()
{
    return TrueBlood_Loader::instance();
}
?>